{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Connections02-EmailAddresses.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyM+FnfIg7PoXyXnLlsHQDEM",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/natnew/100-Python-Projects/blob/main/Connections02_EmailAddresses.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Data Creation"
      ],
      "metadata": {
        "id": "XrjjVsAhAnBg"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "The data is created in a dataframe. But this could also be applied to existing data imported into a dataframe. The aim of this graph is to show connections more clearly. This is particularly important with large datasets (BIG DATA). But in this instance we are using a sample dataset. You may want to show connections as a way of determining risk (duplicated data in a database) or for other reasons. "
      ],
      "metadata": {
        "id": "o7NlymUfApUW"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "9CYEubwN_mLN",
        "outputId": "3df3684c-e48d-4f9a-d036-322281e02666"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:11: FutureWarning: The pandas.np module is deprecated and will be removed from pandas in a future version. Import numpy directly instead\n",
            "  # This is added back by InteractiveShellApp.init_path()\n"
          ]
        }
      ],
      "source": [
        "import pandas as pd\n",
        "\n",
        "df = pd.DataFrame({'ID':[1,2,3,4,5,6,7,8,9,10,11,12], \n",
        "                   'First Name':['Albert', 'Ben', 'Cathy', 'Dan', 'Eddie','Freddie', 'Jen', 'Jack', 'Dennis', 'Jenifer', 'Penny', 'Rubbie'], \n",
        "                   'Family Name': ['Ander','Brooks','Colt','Deen','Evergreen','Revert', 'Den', 'Scott', 'Hull', 'Conrad', 'Donovan', 'Risk'],\n",
        "                   'Phone number': ['+44 2910987263','+44 8873627192','+44 0987678922', '+44 0987776662','+44 2910987263', '+44 8873627192', '+44 0006728394', '+44 5557773900', '+44 2733425678', '+44 0008192028', '+44 8873627192', '+44 0008192028'],\n",
        "                   'Email': ['a.ander@gmail.com','b.brooks@gmil.com','cathy.colt@gmail.com','a.ander@gmail.com','b.brooks@gmil.com','freddie.revert@gmail.com', 'jen.den@gmail.com', 'j.same@gmail.com', pd.np.nan, 'j.same@gmail.com', pd.np.nan, pd.np.nan]})\n"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Individuals who have the same phone number are connected using their ID. But this can apply to other bits of information. For exmapl, you may want to connect individuals that share the same last name, address (if that was a data point) and other information. "
      ],
      "metadata": {
        "id": "imU5aocGXidB"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "column_edge = 'Phone number'\n",
        "column_ID = 'ID'\n",
        "\n",
        "data_to_merge = df[[column_ID, column_edge]].dropna(subset=[column_edge]).drop_duplicates() # select columns, remove NaN\n",
        "\n",
        "# To create connections between people who have the same number,\n",
        "# join data with itself on the 'ID' column.\n",
        "data_to_merge = data_to_merge.merge(\n",
        "    data_to_merge[[column_ID, column_edge]].rename(columns={column_ID:column_ID+\"_2\"}), \n",
        "    on=column_edge\n",
        ")"
      ],
      "metadata": {
        "id": "Z9ffk1jT_r5o"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "data_to_merge"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 739
        },
        "id": "_xtDquXYYfHN",
        "outputId": "632a6cd0-126e-4685-b9f8-87d8958c3126"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "    ID    Phone number  ID_2\n",
              "0    1  +44 2910987263     1\n",
              "1    1  +44 2910987263     5\n",
              "2    5  +44 2910987263     1\n",
              "3    5  +44 2910987263     5\n",
              "4    2  +44 8873627192     2\n",
              "5    2  +44 8873627192     6\n",
              "6    2  +44 8873627192    11\n",
              "7    6  +44 8873627192     2\n",
              "8    6  +44 8873627192     6\n",
              "9    6  +44 8873627192    11\n",
              "10  11  +44 8873627192     2\n",
              "11  11  +44 8873627192     6\n",
              "12  11  +44 8873627192    11\n",
              "13   3  +44 0987678922     3\n",
              "14   4  +44 0987776662     4\n",
              "15   7  +44 0006728394     7\n",
              "16   8  +44 5557773900     8\n",
              "17   9  +44 2733425678     9\n",
              "18  10  +44 0008192028    10\n",
              "19  10  +44 0008192028    12\n",
              "20  12  +44 0008192028    10\n",
              "21  12  +44 0008192028    12"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-cd4c4716-7e4f-4fe5-8e08-968317e6511d\">\n",
              "    <div class=\"colab-df-container\">\n",
              "      <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ID</th>\n",
              "      <th>Phone number</th>\n",
              "      <th>ID_2</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1</td>\n",
              "      <td>+44 2910987263</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>+44 2910987263</td>\n",
              "      <td>5</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>5</td>\n",
              "      <td>+44 2910987263</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>5</td>\n",
              "      <td>+44 2910987263</td>\n",
              "      <td>5</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>2</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>2</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>6</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>2</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>11</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>6</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>6</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>6</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>6</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>11</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>10</th>\n",
              "      <td>11</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>11</th>\n",
              "      <td>11</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>6</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12</th>\n",
              "      <td>11</td>\n",
              "      <td>+44 8873627192</td>\n",
              "      <td>11</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>13</th>\n",
              "      <td>3</td>\n",
              "      <td>+44 0987678922</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>4</td>\n",
              "      <td>+44 0987776662</td>\n",
              "      <td>4</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>15</th>\n",
              "      <td>7</td>\n",
              "      <td>+44 0006728394</td>\n",
              "      <td>7</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>16</th>\n",
              "      <td>8</td>\n",
              "      <td>+44 5557773900</td>\n",
              "      <td>8</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>17</th>\n",
              "      <td>9</td>\n",
              "      <td>+44 2733425678</td>\n",
              "      <td>9</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>18</th>\n",
              "      <td>10</td>\n",
              "      <td>+44 0008192028</td>\n",
              "      <td>10</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>19</th>\n",
              "      <td>10</td>\n",
              "      <td>+44 0008192028</td>\n",
              "      <td>12</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>20</th>\n",
              "      <td>12</td>\n",
              "      <td>+44 0008192028</td>\n",
              "      <td>10</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>21</th>\n",
              "      <td>12</td>\n",
              "      <td>+44 0008192028</td>\n",
              "      <td>12</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-cd4c4716-7e4f-4fe5-8e08-968317e6511d')\"\n",
              "              title=\"Convert this dataframe to an interactive table.\"\n",
              "              style=\"display:none;\">\n",
              "        \n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "       width=\"24px\">\n",
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
              "  </svg>\n",
              "      </button>\n",
              "      \n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      flex-wrap:wrap;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "      <script>\n",
              "        const buttonEl =\n",
              "          document.querySelector('#df-cd4c4716-7e4f-4fe5-8e08-968317e6511d button.colab-df-convert');\n",
              "        buttonEl.style.display =\n",
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "        async function convertToInteractive(key) {\n",
              "          const element = document.querySelector('#df-cd4c4716-7e4f-4fe5-8e08-968317e6511d');\n",
              "          const dataTable =\n",
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                     [key], {});\n",
              "          if (!dataTable) return;\n",
              "\n",
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "            + ' to learn more about interactive tables.';\n",
              "          element.innerHTML = '';\n",
              "          dataTable['output_type'] = 'display_data';\n",
              "          await google.colab.output.renderOutput(dataTable, element);\n",
              "          const docLink = document.createElement('div');\n",
              "          docLink.innerHTML = docLinkHtml;\n",
              "          element.appendChild(docLink);\n",
              "        }\n",
              "      </script>\n",
              "    </div>\n",
              "  </div>\n",
              "  "
            ]
          },
          "metadata": {},
          "execution_count": 69
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We can have a look at the data. Grouping similar numbers close together. "
      ],
      "metadata": {
        "id": "WzBtMMmgYiHC"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# By joining the data with itself, people will have a connection with themselves.\n",
        "# Remove self connections, to keep only connected people who are different.\n",
        "d = data_to_merge[~(data_to_merge[column_ID]==data_to_merge[column_ID+\"_2\"])] \\\n",
        "    .dropna()[[column_ID, column_ID+\"_2\", column_edge]]\n",
        "    \n",
        "# To avoid counting twice the connections (person 1 connected to person 2 and person 2 connected to person 1)\n",
        "# we force the first ID to be \"lower\" then ID_2\n",
        "d.drop(d.loc[d[column_ID+\"_2\"]<d[column_ID]].index.tolist(), inplace=True)"
      ],
      "metadata": {
        "id": "WS5iwA10_v44"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "d"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 206
        },
        "id": "J1L98efeYroc",
        "outputId": "b10687a2-04d9-4ec9-df0a-da018317fc86"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "    ID  ID_2    Phone number\n",
              "1    1     5  +44 2910987263\n",
              "5    2     6  +44 8873627192\n",
              "6    2    11  +44 8873627192\n",
              "9    6    11  +44 8873627192\n",
              "19  10    12  +44 0008192028"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-d3685f53-c8c9-4b63-b3f1-0d0b83eb3508\">\n",
              "    <div class=\"colab-df-container\">\n",
              "      <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ID</th>\n",
              "      <th>ID_2</th>\n",
              "      <th>Phone number</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>5</td>\n",
              "      <td>+44 2910987263</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>2</td>\n",
              "      <td>6</td>\n",
              "      <td>+44 8873627192</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>2</td>\n",
              "      <td>11</td>\n",
              "      <td>+44 8873627192</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>6</td>\n",
              "      <td>11</td>\n",
              "      <td>+44 8873627192</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>19</th>\n",
              "      <td>10</td>\n",
              "      <td>12</td>\n",
              "      <td>+44 0008192028</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-d3685f53-c8c9-4b63-b3f1-0d0b83eb3508')\"\n",
              "              title=\"Convert this dataframe to an interactive table.\"\n",
              "              style=\"display:none;\">\n",
              "        \n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "       width=\"24px\">\n",
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
              "  </svg>\n",
              "      </button>\n",
              "      \n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      flex-wrap:wrap;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "      <script>\n",
              "        const buttonEl =\n",
              "          document.querySelector('#df-d3685f53-c8c9-4b63-b3f1-0d0b83eb3508 button.colab-df-convert');\n",
              "        buttonEl.style.display =\n",
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "        async function convertToInteractive(key) {\n",
              "          const element = document.querySelector('#df-d3685f53-c8c9-4b63-b3f1-0d0b83eb3508');\n",
              "          const dataTable =\n",
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                     [key], {});\n",
              "          if (!dataTable) return;\n",
              "\n",
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "            + ' to learn more about interactive tables.';\n",
              "          element.innerHTML = '';\n",
              "          dataTable['output_type'] = 'display_data';\n",
              "          await google.colab.output.renderOutput(dataTable, element);\n",
              "          const docLink = document.createElement('div');\n",
              "          docLink.innerHTML = docLinkHtml;\n",
              "          element.appendChild(docLink);\n",
              "        }\n",
              "      </script>\n",
              "    </div>\n",
              "  </div>\n",
              "  "
            ]
          },
          "metadata": {},
          "execution_count": 71
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        " We will now create the graph. "
      ],
      "metadata": {
        "id": "TH8KPB7dYyDO"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import networkx as nx\n",
        "\n",
        "G = nx.from_pandas_edgelist(df=d, source=column_ID, target=column_ID+'_2', edge_attr=column_edge)\n",
        "\n",
        "G.add_nodes_from(nodes_for_adding=df.ID.tolist())"
      ],
      "metadata": {
        "id": "wre1wtFj_x6W"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "G.nodes()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "MleGBgAK_9Bh",
        "outputId": "8f9d0806-957d-4387-ed58-04f2a7c5dd74"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "NodeView((1, 5, 2, 6, 11, 10, 12, 3, 4, 7, 8, 9))"
            ]
          },
          "metadata": {},
          "execution_count": 73
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We will now connect similar email addresses. "
      ],
      "metadata": {
        "id": "c_zvqDdlY3P7"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "column_edge = 'Email'\n",
        "column_ID = 'ID'\n",
        "\n",
        "data_to_merge = df[[column_ID, column_edge]].dropna(subset=[column_edge]).drop_duplicates()\n",
        "\n",
        "data_to_merge = data_to_merge.merge(\n",
        "    data_to_merge[[column_ID, column_edge]].rename(columns={column_ID:column_ID+\"_2\"}), \n",
        "    on=column_edge\n",
        ")\n",
        "\n",
        "d = data_to_merge[~(data_to_merge[column_ID]==data_to_merge[column_ID+\"_2\"])] \\\n",
        "    .dropna()[[column_ID, column_ID+\"_2\", column_edge]]\n",
        "\n",
        "d.drop(d.loc[d[column_ID+\"_2\"]<d[column_ID]].index.tolist(), inplace=True)"
      ],
      "metadata": {
        "id": "Qo4h06PI__In"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "d"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 143
        },
        "id": "txm8LI1bAA8x",
        "outputId": "41092285-29c1-415d-bb4d-adb748e1d703"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "    ID  ID_2              Email\n",
              "1    1     4  a.ander@gmail.com\n",
              "5    2     5  b.brooks@gmil.com\n",
              "12   8    10   j.same@gmail.com"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-636a3274-ab5b-478b-b8d2-c5df1bfc5500\">\n",
              "    <div class=\"colab-df-container\">\n",
              "      <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ID</th>\n",
              "      <th>ID_2</th>\n",
              "      <th>Email</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1</td>\n",
              "      <td>4</td>\n",
              "      <td>a.ander@gmail.com</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>2</td>\n",
              "      <td>5</td>\n",
              "      <td>b.brooks@gmil.com</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12</th>\n",
              "      <td>8</td>\n",
              "      <td>10</td>\n",
              "      <td>j.same@gmail.com</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-636a3274-ab5b-478b-b8d2-c5df1bfc5500')\"\n",
              "              title=\"Convert this dataframe to an interactive table.\"\n",
              "              style=\"display:none;\">\n",
              "        \n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "       width=\"24px\">\n",
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
              "  </svg>\n",
              "      </button>\n",
              "      \n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      flex-wrap:wrap;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "      <script>\n",
              "        const buttonEl =\n",
              "          document.querySelector('#df-636a3274-ab5b-478b-b8d2-c5df1bfc5500 button.colab-df-convert');\n",
              "        buttonEl.style.display =\n",
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "        async function convertToInteractive(key) {\n",
              "          const element = document.querySelector('#df-636a3274-ab5b-478b-b8d2-c5df1bfc5500');\n",
              "          const dataTable =\n",
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                     [key], {});\n",
              "          if (!dataTable) return;\n",
              "\n",
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "            + ' to learn more about interactive tables.';\n",
              "          element.innerHTML = '';\n",
              "          dataTable['output_type'] = 'display_data';\n",
              "          await google.colab.output.renderOutput(dataTable, element);\n",
              "          const docLink = document.createElement('div');\n",
              "          docLink.innerHTML = docLinkHtml;\n",
              "          element.appendChild(docLink);\n",
              "        }\n",
              "      </script>\n",
              "    </div>\n",
              "  </div>\n",
              "  "
            ]
          },
          "metadata": {},
          "execution_count": 75
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We can view our analysis as a graph using Matplotlib. "
      ],
      "metadata": {
        "id": "VEYn4apaY9IU"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "%matplotlib inline"
      ],
      "metadata": {
        "id": "s5G9WC90AC04"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Each time we run this, we get a new set of connections. "
      ],
      "metadata": {
        "id": "vnQUqwKqZF0x"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "nx.draw(G)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 319
        },
        "id": "nqwk8AbqAER6",
        "outputId": "8e7ecc9a-2735-42ba-f456-f0b2e8d8e1fb"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAb4AAAEuCAYAAADx63eqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAARz0lEQVR4nO3dT0ikeX7H8c9jPbU+Lm3RpLuyCprpyRRtTQ5t0BAaFsYSNgxICAnYbA7NHnfBhpC7Z6+Zk7KQY/oyUISQsC5sCJYsCX2IzuoGLJ0K6azFaihdasoiVlF/nhxcp9tMa2vV89Tz5/d+Haet7/yEbt8+Vc/z+1mu67oCAMAQQ0EvAACAQSJ8AACjED4AgFEIHwDAKIQPAGAUwgcAMArhAwAYhfABAIxC+AAARiF8AACjED4AgFEIHwDAKIQPAGAUwgcAMArhAwAYhfABAIxiB70AoBcn9abyW2UVj2uqNdpKObayYyk9m53Qg3vDoZkJIHwsTmBHlOwcVrVaKGnzoCJJara7X/+ZYw/JlZSbSmtpLqPpyfuBzQQQXoQPkfHy1WutrBfVaHd0099ay5IcO6HlhayeP3008JkAwo3wIRIuArWn81b3/V/8WyPJIS0vfHxtqPyYCSD8uLkFobdzWNXKevFOgZKk81ZXK+tF7ZarA5kJIBoIH0JvtVBSo93p6bWNdkdrhdJAZgKIBsKHUDupN7V5ULnx87ebuK60sV/Rab3p60wA0UH4EGr5rXLfMyxJ+e03c/yYCSA6eI4PoVY8rl15vKAXjXZXvzz8jarVB3JdVzv/feLJzOLRWV8zAASDKz6EWq3R9mTO3//TT/XBBx/oww8/1D/+9GeezKw1Wp7MATBYhA+hlnK8eVPi+3/xZ/rqq69UrVb17M//1JOZKSfpyRwAg0X4EGrZsZSG7f7+mjr2kLLjo77OBBAdhA+htjg70fcMV9LizJs5fswEEB2ED6H28N6w5h6nZVm9vd6ypPmp9JVNpv2YCSA6CB9C70UuI8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p2eXttod7RWKHm8IgCAyXwN30m9qc2Dyo2f6d3EdaWN/YpO601vFwYAMJav4ctvlfueYUnKb/c/BwAAyefwFY9rVx5Z6EWj3VXx6MyjFQEATOdr+GqNtkdzWp7MAQDA1/ClHG+elkg5SU/mAADga/iyYykN2/39Lxx7SNnxUY9WBAAwna/hW5yd6HuGK2lxpv85AABIPofv4b1hzT1Oy7J6e71lXZwvxcbVAACv+L5l2YtcRj//8kTnrbs/xO7YCS3lMj6sCjATJ6MAA9qk+i57dV4aSQ5peeFj9uoEPMDJKMAbnM6Ad+LKID74twdcNdDz+HbLVa0VStrYr8jSxcPply5/65yfSmspl9GTCX7rDAJXBvHCuy3ANw00fJdO603lt8sqHp2p1mgp5SSVHR/V4gxXE0HiyiBedg6r+su/fdXT5+sjyYQ+/+FTfgFFLAUSPoQPVwbx88O/+3f9897/9LRJvGVJn/7Bd/Tj53/k/cKAgPl+LBHCjzMT44eTUYDrET5wZmIMcTIKcD3CZziuDOKJk1GA6xE+w3FlEE+cjAJcj/AZjiuDeOJkFOB6hM9wXBnEEyejANcjfIbjyiCeOBkFuB7hMxxXBvHEySjA9Qif4bgyiK8XuYwcO9HTazkZBXFG+AzHlUF8TU/e1/JCViPJu/0zv9iRJ8t2ZYgtwgeuDGLs+dNHWl74WCPJxHt/ubGsiz062YYOccdenZDEXp1xx8kowBuED1/jdIb442QUgPDh/+HKAEDcET68E1cGAOKK8AEAjMJdnQAAoxA+AIBRCB8AwCiEDwBgFMIHADAK4QMAGIXwAQCMQvgAAEYhfAAAo/wfeK2aXuntW68AAAAASUVORK5CYII=\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "{row[column_ID]:row['First Name'] +' '+ row['Family Name'] for i,row in df.iterrows()}"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "fvl3O3yBALqr",
        "outputId": "a596867e-8ff0-4033-cfed-95685c4586c2"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "{1: 'Albert Ander',\n",
              " 2: 'Ben Brooks',\n",
              " 3: 'Cathy Colt',\n",
              " 4: 'Dan Deen',\n",
              " 5: 'Eddie Evergreen',\n",
              " 6: 'Freddie Revert',\n",
              " 7: 'Jen Den',\n",
              " 8: 'Jack Scott',\n",
              " 9: 'Dennis Hull',\n",
              " 10: 'Jenifer Conrad',\n",
              " 11: 'Penny Donovan',\n",
              " 12: 'Rubbie Risk'}"
            ]
          },
          "metadata": {},
          "execution_count": 78
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "nx.set_node_attributes(G, {row[column_ID]:{'Name': row['First Name'] +' '+ row['Family Name']} for i,row in df.iterrows()})"
      ],
      "metadata": {
        "id": "P9x9sa_KAOkM"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "EDGE_SIZE = {\n",
        "    'Phone number': 2,\n",
        "    'Email': 1,\n",
        "}\n",
        "\n",
        "EDGE_COLOR = {\n",
        "    'Phone number': 'purple',\n",
        "    'Email': 'red',\n",
        "}\n",
        "\n",
        "def clean_edge(edge):\n",
        "    s.edge[edge[0], edge[1]].values()\n",
        "\n",
        "def c_(list_edges): return [a for a in list_edges if a in list(EDGE_COLOR.keys())]\n",
        "    \n",
        "# For nx.Graph()\n",
        "def edge_sizes(s): return [EDGE_SIZE[c_(list(s.edges[edge[0], edge[1]].keys()))[-1]] for edge in s.edges()] # /!\\ multiple links => one size\n",
        "def edge_colors(s): return [EDGE_COLOR[c_(list(s.edges[edge[0], edge[1]].keys()))[-1]] for edge in s.edges()] # /!\\ multiple links => one color\n",
        "\n",
        "# For nx.MultiDiGraph()\n",
        "# def edge_sizes(s): return [EDGE_SIZE[s.edge[edge[0]][edge[1]][0]['label']] for edge in s.edges()] # /!\\ multiple links => one size\n",
        "# def edge_colors(s): return [EDGE_COLOR[s.edge[edge[0]][edge[1]][0]['label']] for edge in s.edges()] # /!\\ multiple links => one color\n",
        "\n",
        "def draw(s):\n",
        "    pos = nx.spring_layout(s, scale=0.5)\n",
        "    node_labels = dict((n,d['Name']) for n,d in s.nodes(data=True))\n",
        "#     labels = {**node_labels, **edge_labels}\n",
        "    nx.draw(s, pos=pos, width=edge_sizes(s), edge_color=edge_colors(s), alpha=0.8, arrows=False, node_color='lightgrey', node_size=400,\n",
        "            labels=node_labels, \n",
        "            font_color='black', font_size=8, font_weight='bold',\n",
        "           )\n",
        "    edge_labels = dict(((u,v),list(d.values())[0]) for u,v,d in G.edges(data=True))\n",
        "    nx.draw_networkx_edge_labels(G, pos, edge_labels = edge_labels, font_size=8)"
      ],
      "metadata": {
        "id": "kZyoDk2JAQha"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "draw(nx.ego_graph(G=G, n=1, radius=3))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 636
        },
        "id": "NjN35R0MASeg",
        "outputId": "21aeeba7-b978-4580-c555-d69e04c3f819"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "KeyError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-81-0ca093e388aa>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mego_graph\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mG\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mG\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mradius\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
            "\u001b[0;32m<ipython-input-80-ead64e71565d>\u001b[0m in \u001b[0;36mdraw\u001b[0;34m(s)\u001b[0m\n\u001b[1;32m     31\u001b[0m            )\n\u001b[1;32m     32\u001b[0m     \u001b[0medge_labels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mu\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0md\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mG\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0medges\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m     \u001b[0mnx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw_networkx_edge_labels\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mG\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpos\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0medge_labels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0medge_labels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfont_size\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
            "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/networkx/drawing/nx_pylab.py\u001b[0m in \u001b[0;36mdraw_networkx_edge_labels\u001b[0;34m(G, pos, edge_labels, label_pos, font_size, font_color, font_family, font_weight, alpha, bbox, horizontalalignment, verticalalignment, ax, rotate, clip_on)\u001b[0m\n\u001b[1;32m   1105\u001b[0m     \u001b[0mtext_items\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1106\u001b[0m     \u001b[0;32mfor\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mn1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabel\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1107\u001b[0;31m         \u001b[0;34m(\u001b[0m\u001b[0mx1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mn1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1108\u001b[0m         \u001b[0;34m(\u001b[0m\u001b[0mx2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mn2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1109\u001b[0m         (x, y) = (\n",
            "\u001b[0;31mKeyError\u001b[0m: 2"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAb4AAAEuCAYAAADx63eqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAcfUlEQVR4nO3deXDU9cHH8c9uko1ZEpdwxIBEDAQEosiRhz5qISDz0AlaBAQtKtUSiQlgi7ZqHNop5cFBmMrhAQMDtVYR6wHUqq3IYQIiovAoyCGFxCBHOJMQkrC77P6eP2i2BBLIsckev/drxhkkv12+ZsZ589nsYTEMwxAAACZhDfQBAABoSYQPAGAqhA8AYCqEDwBgKoQPAGAqhA8AYCqEDwBgKoQPAGAqhA8AYCqEDwBgKoQPAGAqhA8AYCqEDwBgKoQPAGAqhA8AYCqEDwBgKoQPAGAqhA8AYCqEDwBgKoQPAGAqhA8AYCqRgT4AACC0OJ1OlZWVqbKyUi6XS4ZhyGKxyGazyW63y+FwKDo6OtDHrJPFMAwj0IcAAAQ/t9ut4uJiVVVV+WJnsVh8XzcMw/f7MTExSkxMVFRUVABPXDvCBwC4qvLychUXF8vr9cpqtdYI3qUMw/Bdl5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swjz76SL/73e80fvx4bd68Wc8++6zWrFmjw4cP66abbtL+/ftVUVGhxYsXa82aNdqzZ4+GDRumXr16BfroQFggfEALW7BggXr06KGf/OQnWrlypVasWKF33nlHy5cv15EjR3T//ffro48+UnZ2dqCPCoQlHuoEmpnL5dKqVatUXFwsSerevbtefvllud1ujR49WvHx8XrhhRf04IMPauLEiZo/f76++eYbuVwu8fdSwP8IH9BMDMPQoUOHlJ6erhdffFFr166V2+1WRkaG+vTpowULFkiSZs2apR07dujs2bPasGGDevTooUWLFslms/GhsUAz4L06gWbg9XpltVrVsWNHLViwQIZh6PPPP9fmzZuVnp6uSZMmKTs7W+np6Wrbtq3atGmj2NhYjRo1KtBHB8Ieiw/ws08++UT33HOP3njjDX311VcaMGCAUlNTFR8fr6+//loFBQXq0KGDcnJytGzZMj388MPq3LlzoI8NmAZPbgH8qLCwULm5uZo0aZKcTqfeeOMN5ebmqlevXtq1a5fWr1+vLl26qH///mrTpo2ioqJUUlLCm0oDLYjFB/hB9TupJCQkyOl0KiUlRcOGDdN1112nuXPnSpJSU1OVlpamRYsW6Wc/+5m+/vprWSwWoge0MMIHNIHL5dLTTz+tCRMmaOnSpTpy5IjGjRunF154QZLUvn17OZ1OrV+/XpKUl5enqKgoLVmyRAMGDAjk0QHTInxAI3m9Xs2cOVPnz5/XwoULderUKR04cEAjR46UJN1///06duyYBg0apNatW0uSRo8erVWrVql79+6BPDpgavyMD2iCw4cP6/rrr5ckLVmyRDt27NDLL78swzDk8XhksVg0ZcoUjRkzRkOHDg3waQFILD6gQU6ePFnj3xMTE32/Tk1NVc+ePSVJFotFpaWlGj58uFJTU4keEEQIH1BPL7/8sh599FHfZ+VJUkREhO/Xe/bs0XXXXafjx4/rH//4h9q1a6cVK1ZoypQpgTgugDoQPqCeunfvrrNnz2rjxo2+tx8zDMP3tmJHjhzRypUrdd9996mkpESSeMYmEIQIH1CH8+fP11h3FotFPXr0kMPhUH5+vu/3qkVFRen777/Xn/70Jz3wwAMtfl4A9U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lyeHw6G+ffteMXzz58/XkCFDtGDBAkkXVmFWVpYGDhyoyZMn6+jRozp+/LhGjRqlWbNmafz48Zo9e7bOnTunv/71r8rKypK7wq2SgpILD21apJ37d2rAbQNks9m0detWSdK6det07733asaMGUpPT9fcuXMlSfv27dOIESM0duxYHTp0yHeurVu36t5771V6erqef/55GYbhW6nTpk1TRkaGP75NAIAg4Jfw5efnq3///howYIB27typ06dP13rdzTffrMzMTL3++usqKirS/PnzVVpaqmXLlunUqVNavny5b615PB49//zzmjhxoqKjo/XTn/5Us2fPlrvSLa/bq8iYSLliXTp09JD69eunHj16+MInXVh9KSkpGjFihN566y253W4tWrRI11xzjWbNmqWTJ09KurDmpk2bpp49e+qVV17R6tWrtWHDBt/9dO7cWYsXL/bHtwkAEASaHL59+/b5fp6XlpYmr9erTZs21Xptenq6Bg0aJEn64YcfVFhYqKKiImVmZqqwsFD79++vce3111+vdu3ayWKxyG63Kz4+XvZ2dsV2iFXrG1tr2/9tkySlpqbqlltu0cGDB1VcXOy7j9tuu03dunWT1+tVZWWlDh48qFtvvVUpKSlKTU2VJJWWlqqkpETr169XTk6OPB6Pdu/e7buP0aNH68Ybb2zqtwkAECSa/KzO6oc258yZ4/u9Tz/9VGlpabVee+7chWdfJiUlKTk5WREREcrOzpbb7VZBQYHv2ouf1RkVFaUTJ06orKxMDodD17S+RpJ8C2/q1Km+a7du3apWrVr57qN6QRqGoRtuuEE7duzQ/v37tWvXLtlsNrVu3Vrx8fHq16+fRowYoZMnTyopKUmHD1/4eWFkZNA98RUA0ARNXnx5eXm6+eab9eabb+rNN9/U3XffrS+++MIXuIt9++23Wrp0qcaPH6/OnTtr6tSpcjgcmjZtmubNmyev16vaXlY4cOBA5eXl6fnnn/f9Xnl5uXbv3q2MjAzNnTtXc+fOVVJSki+GhmHIZrPVuJ+cnBxVVVXp6aefVps2bS58A6xWPffccyooKNBTTz2l5cuXEzsACGNB9QL248ePq6SkpN6v4bsSj8ej+Ph4JSQk+OFkAIBwEVSv8HY4HLJYLLWuvoaovr3D4fDHsQAAYSSowhcdHa2YmJgmv27O6/XKbrfX+VFFAADzCqrwSVJiYqKsVmuj43fxpzQAAHCpoAtfVFSUL1oNjV/19Rd/Lh8AABcLyqcvxsXFSbrwhtUej6fBn8dXfXsAAC4VVM/qvFT1J7BXVlZKUp2fwC5JdrudpQcAuKqgDl81p9OpsrIyVVZWyuVy+d7I2mazyW63y+Fw8EQWAEC9hET4AADwl6B7cgsAAM2J8AEATIXwAQBMhfABAEyF8AEATIXwAQBMhfABAEyF8AEATIXwAQBMhfABAEyF8AEATIXwAQBMhfABAEyF8AEATIXwAQBMhfABAEyF8AEATIXwAQBMhfABAEyF8AEATOX/AQKL0PMGuX+kAAAAAElFTkSuQmCC\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "We will now detect peculiar patterns in our data. "
      ],
      "metadata": {
        "id": "WbEqX8p2ZPKJ"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "degrees = list(nx.degree(G))"
      ],
      "metadata": {
        "id": "10BCPTLaAUnU"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "pd.DataFrame([list(d) for d in degrees], columns=['ID', 'degree']).sort_values('degree', ascending=False).head(5)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 206
        },
        "id": "45R6ObuiAWrd",
        "outputId": "7d351211-3c18-4a6b-c8fd-e65a9ff5274a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "   ID  degree\n",
              "2   2       2\n",
              "3   6       2\n",
              "4  11       2\n",
              "0   1       1\n",
              "1   5       1"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-9c2d158b-77d8-4760-94e2-dfa47f081f3e\">\n",
              "    <div class=\"colab-df-container\">\n",
              "      <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ID</th>\n",
              "      <th>degree</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>2</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>6</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>11</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>5</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-9c2d158b-77d8-4760-94e2-dfa47f081f3e')\"\n",
              "              title=\"Convert this dataframe to an interactive table.\"\n",
              "              style=\"display:none;\">\n",
              "        \n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "       width=\"24px\">\n",
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
              "  </svg>\n",
              "      </button>\n",
              "      \n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      flex-wrap:wrap;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "      <script>\n",
              "        const buttonEl =\n",
              "          document.querySelector('#df-9c2d158b-77d8-4760-94e2-dfa47f081f3e button.colab-df-convert');\n",
              "        buttonEl.style.display =\n",
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "        async function convertToInteractive(key) {\n",
              "          const element = document.querySelector('#df-9c2d158b-77d8-4760-94e2-dfa47f081f3e');\n",
              "          const dataTable =\n",
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                     [key], {});\n",
              "          if (!dataTable) return;\n",
              "\n",
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "            + ' to learn more about interactive tables.';\n",
              "          element.innerHTML = '';\n",
              "          dataTable['output_type'] = 'display_data';\n",
              "          await google.colab.output.renderOutput(dataTable, element);\n",
              "          const docLink = document.createElement('div');\n",
              "          docLink.innerHTML = docLinkHtml;\n",
              "          element.appendChild(docLink);\n",
              "        }\n",
              "      </script>\n",
              "    </div>\n",
              "  </div>\n",
              "  "
            ]
          },
          "metadata": {},
          "execution_count": 83
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "draw(nx.ego_graph(G=G, n=3, radius=2))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 636
        },
        "id": "Lh9PSoEhAX5m",
        "outputId": "8382420a-9646-4295-fd06-0ea601b7b55a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "KeyError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-84-ba837033a95d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mego_graph\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mG\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mG\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mradius\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
            "\u001b[0;32m<ipython-input-80-ead64e71565d>\u001b[0m in \u001b[0;36mdraw\u001b[0;34m(s)\u001b[0m\n\u001b[1;32m     31\u001b[0m            )\n\u001b[1;32m     32\u001b[0m     \u001b[0medge_labels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mu\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0md\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mG\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0medges\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m     \u001b[0mnx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw_networkx_edge_labels\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mG\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpos\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0medge_labels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0medge_labels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfont_size\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
            "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/networkx/drawing/nx_pylab.py\u001b[0m in \u001b[0;36mdraw_networkx_edge_labels\u001b[0;34m(G, pos, edge_labels, label_pos, font_size, font_color, font_family, font_weight, alpha, bbox, horizontalalignment, verticalalignment, ax, rotate, clip_on)\u001b[0m\n\u001b[1;32m   1105\u001b[0m     \u001b[0mtext_items\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1106\u001b[0m     \u001b[0;32mfor\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mn1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabel\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1107\u001b[0;31m         \u001b[0;34m(\u001b[0m\u001b[0mx1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mn1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1108\u001b[0m         \u001b[0;34m(\u001b[0m\u001b[0mx2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mn2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1109\u001b[0m         (x, y) = (\n",
            "\u001b[0;31mKeyError\u001b[0m: 1"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAb4AAAEuCAYAAADx63eqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAJ8ElEQVR4nO3dP2hd9f/H8XeSb1JM0RgabfxTSuoggopQQa0KxiHSSaSig01BELspVrBDFwXBaop0cigiVAsVsjm1SrOVDlV0EKkoCdIY01gaSm1CUpP7nXJpftr8vkpjv9++Ho8p3Ps553y4yzPnnns+p6XRaDQKAEK0XusJAMA/SfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKL861pPAFLMzc3V+fPna2Zmpubn56vRaFRLS0t1dHRUZ2dndXV11Zo1a671NOG619JoNBrXehJwPbt06VJNTk7W7OxsM3YtLS3N9xuNRvP1G264oXp7e6u9vf0azhiub8IHq+jChQs1OTlZi4uL1drauix4/1ej0WiO6+3trRtvvPEfnCnkED5YJRcuXKhffvmlqqpaW//zy+mLi4tVVXXbbbeJH6wCP26BVbD09WbVX4ve5eMnJyfr0qVLV31ukE74YBVc/vXm39Ha2lqLi4vNeAJXj/DB/+PLL7+swcHBeuyxx2rbtm31/fffX3Hs8PBwff755zU7O1vfffddPfPMM/XDDz/85WMeP368XnvttXr66afr+eefr6mpqT8dNzExUQ8++GAdO3asfv311zpw4EBNTEz85eNBEuGDFUxMTNQrr7xSfX199fHHH9fOnTtrfn7+iuOHh4friy++aP5K8+84depU7du3rzZv3lxDQ0O1devWFY+5ZCl8S9cVgT8nfLCCI0eO1MLCQu3evbs2bdpUAwMDdd9999WJEydqYGCgtmzZUoODg3X69Ok6cOBAjY6O1tGjR2vbtm3NfXz22We1ffv2eu+992pxcbFeeuml+vTTT6uq6v3336+33npr2TFHRkaqu7u7BgcHa8OGDfXEE0/UnXfeWRMTE/Xyyy/X448/Xjt27KjR0dFl2+3evbuqqnbu3Flvvvnm6n4w8D9M+GAFZ86cqZtvvrnWrl277PX169fXvn376tChQ/Xbb7/V4cOH64UXXqiNGzfWww8/XB9++GFzbE9PTz377LN14sSJOnPmTPX399fx48drcXGxvv7663r00UeX7fvs2bN1yy23NG9/WDrb279/f01PT9fBgwerra2t9u7du2y7PXv2VFXV3r17a9euXavxccB1QfhgBevXr2+utnK5ycnJevvtt+vFF1+sn3/+uaampmrt2rXV1tZWHR0dtW7duubYRx55pO66666qqrp48WL19/fX+Ph4HT16tGZmZuqhhx5atu9169bV2bNnm7c1LN1xNDY2Vg888EBt2rSpNm/eXGNjY8u2u+mmm6qqqru7u/k38EfCByt46qmnqrW1td59990aGxurY8eO1bffflvDw8M1NzdXe/bsqZ6enmac1qxZU9PT03Xu3LnmPi5fqaXRaNTtt99ed999d33yySd1//33/+FevSeffLLOnTtXhw4dqvHx8RoZGanx8fHq6+urb775pkZHR+urr76qvr6+ZdstLXf2008/1cWLF1fzY4H/acIHK7jjjjtq//799eOPP9b27dvrgw8+qPb29tq6dWudP3++Dh8+XD09Pc3xAwMDderUqXrjjTdW3G9/f3/Nzs7Wli1b/vDePffcU7t27aqTJ0/W66+/XkeOHKmOjo569dVXq6urq3bs2FG///5785reko0bN9a9995b77zzTh08ePDqfABwHbJyC1xlU1NTNT09XW1tbX/6fqPRqJMnT9bQ0FB99NFHK67OsrCwUN3d3XXrrbeu1nQhjjM+uMq6urqqpaWlrvQ/5cjISA0NDdVzzz23YvSWtu/q6lqVeUIqZ3ywCk6fPl0zMzNXPOv7TywsLFRnZ2dt2LDhKs4McMYHq6C3t7e57NjfcflTGoCrS/hgFbS3tzej9VfjtzTec/lgdXgCO6ySpet3k5OTtbCw4Hl88F/CNT5YZUuPKFq6Cf5KT2Cvqurs7HSmB6tM+OAfMjc311wFZn5+vrmQdUdHR3V2dlZXV1fzJnRg9QgfAFH8uAWAKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIIrwARBF+ACIInwARBE+AKIIHwBRhA+AKMIHQBThAyCK8AEQRfgAiCJ8AEQRPgCiCB8AUYQPgCjCB0AU4QMgivABEEX4AIgifABEET4AoggfAFGED4AowgdAFOEDIMq/ATAUG3brhhxcAAAAAElFTkSuQmCC\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "**Thank you Felix Revert** for your insightful article founder here: https://towardsdatascience.com/getting-started-with-graph-analysis-in-python-with-pandas-and-networkx-5e2d2f82f18e"
      ],
      "metadata": {
        "id": "FOeVcLy1AcA5"
      }
    }
  ]
}